<template>
  <div class="mt-portal-head">
    <div class="search-righttop" @click="gotosearchurl()">
      <img src="../../static/portal-img/search.png" />
    </div>
    <div class="nav-box">
      <span v-show="DataLoading" class="loadingnav"><spinner type="ios-small"></spinner>加载中...</span>
      <div class="nav-box-item" v-for="(data,index) in nav" :key="data.id">
        <a v-if="index == 0" href="#/">推荐</a>
        <a v-else :href="'#/portal/list/' + data.catid ">{{ data.catname  }}</a>
      </div>
    </div>
  </div>
</template>

<script>
import { Scroller, Spinner } from "vux";
export default {
  components: {
    Scroller,
    Spinner
  },
  data() {
    return {
      nav: [],
      DataLoading: true
    };
  },
  mounted() {
    this.getNavData();
  },
  methods: {
    getNavData(){
      return _axios
      .get('api/portal/home/categories')
      .then(response => {
        this.nav = response.data.resp_data;
        this.DataLoading = false;
      });
    },
    gotosearchurl () {
      window.location.href = 'http://search.tongwei.cn/'
    }
  }
};
</script>

<style scoped>
.mt-portal-head {
  position: fixed;
  top: 0;
  bottom: 45px;
  left: 0;
  right: 0;
  height: 45px;
}
.nav-box{
  background-color: #f9f9f9;
  height: 45px;
  width: 1600px;
}
.nav-box-item{
  display: inline-block;
  line-height: 36px;
  width: auto;
  text-align: center;
  font-size: 16px;
  padding: 5px 15px;
}
.nav-box-item  .active {
  color: #008cf0 !important;
}
.search-righttop {
  width: 45px;
  height: 45px;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 4;
  background-color: #f9f9f9;
}
.search-righttop img{
  width: 27px;
  margin: 9px;
}
</style>